package com.itheima;

import java.lang.reflect.Array;

//用方法实现数组遍历
public class ArrTraDemo {
    public static void main(String[] args) {
        int [] arr = {30,50,60,40,20};
        ArrayTraval(arr);
        System.out.println(getMax(arr));
    }
    public static void ArrayTraval(int [] arr){
        for(int i = 0; i < arr.length;i++)
            System.out.print(arr[i] + " ");
        System.out.println();
    }
    public static int getMax(int [] arr){
        int max = arr[0];
        for(int i = 1; i < arr.length;i++)
            if(arr[i] > max)
                max = arr[i];
        return max;
    }
}
